package TemplateMethodPattern.exercise3_1;

import java.io.IOException;
import java.io.InputStream;

public class MyInput extends InputStream {
    private int[] array;
    private int index;

    public MyInput(int[] array) {
        this.array = array;
        this.index = 0;
    }

    @Override
    public int read() throws IOException {
        if (this.index == this.array.length) {
            return -1;
        } else {
            int c = this.array[index];
            this.index = this.index + 1;
            return c;
        }
    }
}
